#define _CRT_SECURE_NO_WARNINGS  1


class Solution {
public:
    bool isword(char s)
    {
        if ((s >= '0' && s <= '9')
            || (s >= 'a' && s <= 'z')
            || (s >= 'A' && s <= 'Z'))
        {
            return true;
        }
        else
            return false;
    }

    bool isPalindrome(string s) {
        if (s.empty())
            return true;

        for (int i = 0; i < s.size(); i++)
        {
            s[i] = tolower(s[i]);
        }

        int left = 0;
        int right = s.size() - 1;
        while (left < right)
        {
            while (left < right && !isword(s[left]))
                left++;
            while (left < right && !isword(s[right]))
                right--;

            if (s[left] != s[right])
                return false;

            left++;
            right--;
        }
        return true;
    }
};